<?php

/*

  Action	$4

  Copper produces an extra $1 this turn.

 */

class Coppersmith extends Card implements iAction, iKingdom, iInfluence, iIntrigue {

    public function __construct() {
        parent::__construct("Coppersmith", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            " Copper produces an extra $1 this turn.");
    }

    public function play(Game $game, $isRealCard) {
        $game->pushCardToInfluence($this);
        $this->influence($game);
    }

    public function influence(Game $game) {
        $copper = new Copper();
        $copper_key = $copper->getKey();

        $names = $game->getPlayersNames();
        foreach ($names as $name) {
            $cards = $game->getAllCards($name);
            foreach ($cards as $card) {
                if ($card->getKey() == $copper_key) {
                    $value = $card->getMoneyValue($game);
                    $new_value = $value->add(1);
                    $card->setMoneyValue($new_value);
                }
            }
        }
        $boardCards = $game->getBoardCardsByPrice();
        foreach ($boardCards as $card) {
            if ($card->getKey() == $copper_key) {
                $value = $card->getMoneyValue($game);
                $new_value = $value->add(1);
                $card->setMoneyValue($new_value);
            }
        }
        
        return true;
    }

}

?>